package com.zhuss.advice.complaint;

import com.zhuss.advice.processor.ComplaintRead;
import com.zhuss.bean.bo.advice.Complaint.DetailComplaintBo;
import com.zhuss.bean.bo.advice.Complaint.SearchComplaintBo;
import com.zhuss.bean.bo.advice.Complaint.weChat.DetailComplaintWeChatBo;
import com.zhuss.bean.bo.advice.Complaint.weChat.SearchComplaintWeChatBo;
import com.zhuss.common.ReadService;
import com.zhuss.exception.WpsException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

/**
 * @Author: zhushanshuo
 * @Date: 2020/3/6 9:27
 */
@Component("complaintReadService")
public class ComplaintReadService implements ReadService<Object, Object> {

    @Autowired
    @Qualifier("complaintRead")
    private ComplaintRead complaintRead;

    @Override
    public Object detail(Object o) throws WpsException {
        DetailComplaintBo bo = (DetailComplaintBo) o;
        Object result = complaintRead.detail(bo.getComplaintId());
        return result;
    }

    @Override
    public Object list(Object o) throws WpsException {
        SearchComplaintBo bo = (SearchComplaintBo) o;
        bo.setCreateId(bo.getConcurrentUserId());
        Object result = complaintRead.list(bo);
        return result;
    }

    /**
     * 审核列表
     * @throws WpsException
     */
    public Object examineList(Object o) throws WpsException {
        SearchComplaintBo bo = (SearchComplaintBo) o;
        Object result = complaintRead.list(bo);
        return result;
    }

    /**
     * 审核列表
     * @throws WpsException
     */
    public Object handleList(Object o) throws WpsException {
        SearchComplaintBo bo = (SearchComplaintBo) o;
        Object result = complaintRead.handleList(bo);
        return result;
    }

    /**
     * 微信个人列表
     * @throws WpsException
     */
    public Object weChatList(Object o) throws WpsException {
        SearchComplaintWeChatBo bo = (SearchComplaintWeChatBo) o;
        bo.setCreateId(bo.getConcurrentUserId());
        bo.setArea(bo.getConcurrentArea());
        SearchComplaintBo scBo = new SearchComplaintBo();
        BeanUtils.copyProperties(bo,scBo);
        Object result = complaintRead.list(scBo);
        return result;
    }

    /**
     * 微信详情
     * @throws WpsException
     */
    public Object weChatDetail(Object o) throws WpsException {
        DetailComplaintWeChatBo bo = (DetailComplaintWeChatBo) o;
        Object result = complaintRead.detail(bo.getComplaintId());
        return result;
    }
}
